//
//  KKTableViewController.m
//  FreightAssistant
//
//  Created by leo on 15/11/1.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "KKTableViewController.h"


@implementation KKTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithHexString: @"#1176c6"];
    
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear: animated];
    
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(listenkeyboardState:) name: UIKeyboardWillShowNotification object: nil];
    
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(listenkeyboardState:) name: UIKeyboardWillHideNotification object: nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear: animated];
    
    [[NSNotificationCenter defaultCenter] removeObserver: self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Notification methods

- (void)listenkeyboardState:(NSNotification*)notification {
    
    if ([notification.name isEqualToString: UIKeyboardWillShowNotification]) {
        
        if (_keyboardStateBlock) {
            _keyboardStateBlock(true);
        }
    }
    else if ([notification.name isEqualToString: UIKeyboardWillHideNotification]) {
        
        if (_keyboardStateBlock) {
            _keyboardStateBlock(false);
        }
    }
}

@end

